@extends('master')

@section('title', '产品管理')

@section('content')
<div class="row">
    <div class="col-md-12">
        @include('message')
        <p class="lead">
            产品管理
            <a class="btn btn-info btn-xs" href="<% route('admin.products.create') %>">添加新产品</a>
        </p>

    </div>
</div>

<div class="row">
    <div class="col-md-12">
        @if($products->count())
        <div class="table-responsive" style="margin-top:10px;background-color:#fff;">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>日期</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($products as $product)
                <tr>
                    <td>
                        <% $product->id %></td>
                    <td>
                        @if( !$product->status )
                        【草稿】
                        @endif
                        <% $product->title %>
                    </td>
                    <td>
                        <% $product->created_at->format('Y-m-d') %>
                    </td>
                    <td>
                        @if( !$product->status )
                        草稿
                        @else
                        已发布
                        @endif
                    </td>
                    <td>
                        <% Form::open(array('route' => array('admin.products.destroy', $product->id), 'method' => 'DELETE', 'class' => 'delete-form form-inline invisible')) %>
                        <% link_to_route('admin.products.edit','编辑',array('id' => $product->id)) %>
                        <button type="submit" class="btn btn-link btn-xs" onclick="if(!confirm('你确定要删除么')){ return false; }">删除</button>
                        <% Form::close() %>
                    </td>
                </tr>
                @endforeach
                </tbody>
                <tfoot>
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>日期</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </tfoot>
            </table>
        </div>

        @else
        <br />
        <div class="alert alert-warning alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            <strong>还没有产品？</strong> 点击上方的“添加新产品”添加吧.
        </div>
        @endif

        <div class="text-center">
            <% $products->links() %>
        </div>
    </div>
</div>
@stop